import request from '@/utils/request';
import * as api from './request-url';
import { getParams } from '@/utils/utils';



//收藏列表
export async function getCollectionList({ userId, keyword, startTime, endTime, pageSize, pageNum }) {
    return request(`${api.getCollectionList}?pageSize=${pageSize}&pageNum=${pageNum}`, {
        method: 'POST',
        body: {
            userId, keyword, startTime, endTime
        },
    });
}
//收藏取消
export async function deleteCollection({ id, userId }) {
    return request(`${api.deleteCollection}`, {
        method: "POST",
        body: {
            id, userId
        }
    });
}
//分享
export async function getShareList({ userId, shareType, text, startTime, endTime, pageSize, pageNum }) {
    return request(`${api.getShareList}?pageSize=${pageSize}&pageNum=${pageNum}`, {
        method: "POST",
        body: {
            userId, shareType, text, startTime, endTime
        }
    });
}
//分享删除
export async function deleteShare({ userId, shareType, id }) {
    return request(`${api.deleteShare}`, {
        method: "POST",
        body: {
            userId, shareType, id
        }
    });
}

//标准列表
export async function getStandardList({ pageSize, currentPage, name, writeUnit }) {
    return request(`${api.getStandardList}?${getParams({ pageSize, currentPage, name, writeUnit })}`);
}
//标准详情id
export async function getStandardInfo({ id }) {
    return request(`${api.getStandardInfo}?${getParams({ id })}`);
}
//标准描述增加
export async function createStandard({ author, chinaTypeNum, content, deft, effectDate, endTime, executeUnit, fileUrl, nationalTypeNum, num, releaseTime, subject, subtitle, tile, type, unit, writeSchool, writeUnit, id,logo }) {
    return request(`${api.createStandard}`, {
        method: 'POST',
        body: {
            author, chinaTypeNum, content, deft, effectDate, endTime, executeUnit, fileUrl, nationalTypeNum, num, releaseTime, subject, subtitle, tile, type, unit, writeSchool, writeUnit, id,logo
        },
    });
}
//标准描述删除
export async function deleteStandard({ id }) {
    return request(`${api.deleteStandard}?${getParams({ id })}`);
}

/////////////     元数据
//标准元数据列表
export async function getBasicFieldInfoList({ id }) {
    return request(`${api.getBasicFieldInfoList}?${getParams({ id })}`);
}

//标准元数据增加/编辑
export async function saveBasicFieldInfo({ id, stId, limits, name, sort, type }) {
    return request(`${api.saveBasicFieldInfo}`, {
        method: 'POST',
        body: {
            id, stId, limits, name, sort, type
        },
    });
}
//元数据选择项增加
export async function saveBasicFieldOptionInfo({ bdId, id, name, value, sort }) {
    return request(`${api.saveBasicFieldOptionInfo}`, {
        method: 'POST',
        body: {
            bdId, id, name, value, sort
        },
    });
}
//元数据选择项数据
export async function getBasicFieldOptionInfoById({ id }) {
    return request(`${api.getBasicFieldOptionInfoById}?${getParams({ id })}`);
}
//元数据选择项删除
export async function deleteBasicFieldOptionInfo({ id }) {
    return request(`${api.deleteBasicFieldOptionInfo}?${getParams({ id })}`);
}
//标准元数据删除
export async function deleteBasicFieldInfo({ id }) {
    return request(`${api.deleteBasicFieldInfo}?${getParams({ id })}`);
}

/////////////     详细数据
//详细标准列表
export async function getStandDetailInfoList({ id }) {
    return request(`${api.getStandDetailInfoList}?${getParams({ id })}`);
}
//详细标准增加/编辑
export async function saveStandDetailInfo({ id, stId, kv }) {
    return request(`${api.saveStandDetailInfo}`, {
        method: 'POST',
        body: {
            id, stId, kv
        },
    });
}
//详细标准删除
export async function deleteStandDetailInfo({ id }) {
    return request(`${api.deleteStandDetailInfo}?${getParams({ id })}`);
}
//详细标准模板导出
export async function downloadStandModel({ id }) {
    return request(`${api.downloadStandModel}?${getParams({ id })}`);
}
//模板导入
// export async function importExcel({ id, file }) {
//     return request(`${api.importExcel}`, {
//         method: 'POST',
//         body: {
//             id, file
//         },
//     });
// }
//详细标准详情
export async function getStandDetailInfo({ id }) {
    return request(`${api.getStandDetailInfo}?${getParams({ id })}`);
}

//科研软件
//获取分类树
export async function getDirs() {
    return request(`${api.getDirs}`);
}
//分类增加编辑
export async function saveDir({ id, name, type, mark, createTime, sort, parentCode }) {
    return request(`${api.saveDir}`, {
        method: 'POST',
        body: {
            id, name, type, mark, createTime, sort, parentCode
        },
    });
}
//分类目录删除
export async function deleteDir({ key }) {
    return request(`${api.deleteDir}?${getParams({ key })}`);
}
//科研软件列表
export async function getKnowledgeByPage({ pageSize, currentPage, author, startTime, endTime, type }) {
    return request(`${api.getKnowledgeByPage}?${getParams({ pageSize, currentPage, author, startTime, endTime, type })}`);
}
//科研软件新增  编辑
export async function saveKnowledge({ addTime, author, belongUnit, content, desc, downloadNum, id, imgUrls, keys, releaseTime, source, subtitle, title, type, visitNum, behaviour , attachment,platform,fileSize }) {
    return request(`${api.saveKnowledge}`, {
        method: 'POST',
        body: {
            addTime, author, belongUnit, content, desc, downloadNum, id, imgUrls, keys, releaseTime, source, subtitle, title, type, visitNum, behaviour, attachment,platform,fileSize
        },
    });
}
//科研软件删除
export async function deleteKnowledge({ id }) {
    return request(`${api.deleteKnowledge}?${getParams({ id })}`);
}
//科研软件详情
export async function getKnowledgeInfo({ id }) {
    return request(`${api.getKnowledgeInfo}?${getParams({ id })}`);
}

///专题
//专题列表
export async function getTopicByPage({ pageSize, currentPage, name, startTime, endTime }) {
    return request(`${api.getTopicByPage}?${getParams({ pageSize, currentPage, name, startTime, endTime })}`);
}
//专题新增  编辑
export async function saveTopic({ cover, id, introduction, knowledgeList, logo, name, resourceList, tags }) {
    return request(`${api.saveTopic}`, {
        method: 'POST',
        body: {
            cover, id, introduction, knowledgeList, logo, name, resourceList, tags
        },
    });
}
//专题删除
export async function deleteTopic({ id }) {
    return request(`${api.deleteTopic}?${getParams({ id })}`);
}
//专题详情
export async function getTopicInfo({ id }) {
    return request(`${api.getTopicInfo}?${getParams({ id })}`);
}
//专题筛选
export async function getKnowledgeListInfos({ }) {
    return request(`${api.getKnowledgeListInfos}?${getParams({})}`);
}
//专题资产筛选
export async function getDataAssetListInfos({ }) {
    return request(`${api.getDataAssetListInfos}?${getParams({})}`);
}


//文件上传
export async function upload({ file }) {
    return request(`${api.upload}`, {
        method: 'POST',
        body: {
            file
        },
    });
}
//字典获取
export async function getByType({ type }) {
    return request(`${api.getByType}?${getParams({ type })}`);
}

//帮助新增/编辑
export async function helpSave({ id, catalog, parentId, title, content, createUser, modifyUser, isDeleted,helpType}) {
    return request(`${api.helpSave}`, {
        method: 'POST',
        body: {
            id, catalog, parentId, title, content, createUser, modifyUser, isDeleted,helpType
        },
    });
}
//帮助删除
export async function helpDelete({ id }) {
    return request(`${api.helpDelete}?${getParams({ id })}`);
}
//通过id获取帮助文档内容
export async function getHelpInfo({ id }) {
    return request(`${api.getHelpInfo}?${getParams({ id })}`);
}
// 获取帮助文档分页
export async function getHelpByPage({ pageSize, pageNum, title, content,catalog,parentId,ids}) {
    return request(`${api.getHelpByPage}?${getParams({ pageSize, pageNum, title, content,catalog,parentId,ids })}`);
}
//获取目录
export async function getHelp({ }) {
    return request(`${api.getHelp}?${getParams({})}`);
}
//意见
//意见分页查询

export async function selectByPage({ pageSize, pageNum, title, state }) {
    return request(`${api.selectByPage}?${getParams({ pageSize, pageNum, title, state })}`);
}
//意见详情
export async function selectById({ id }) {
    return request(`${api.selectById}?${getParams({ id })}`);
}
//意见处理
export async function handle({ id }) {
    return request(`${api.handle}?${getParams({  id })}`);
}
//字典获取
export async function queryCategory({ pid }) {
    return request(`${api.queryCategory}?${getParams({ pid })}`);
}
//字典获取
export async function getUserInfo({  }) {
    return request(`${api.getUserInfo}?${getParams({  })}`);
}